#include "RssChannel.h"
#include "RssItem.h"
#include "RssDef.h"

RssChannel::RssChannel()
{
}

RssChannel::~RssChannel()
{
}

inline std::string& RssChannel::operator[](const std::string &name)
{
	return m_name2value[name];
}

void RssChannel::set(const std::string &name, const std::string &value)
{
    if(name == kPubDate)
	{
	}
	else if(name == kTTL)
	{
	}

    m_name2value[name] = value;
}

std::string RssChannel::operator[](const std::string &name) const
{
    return getValue(name);
}

std::string RssChannel::getValue(const std::string &name) const
{
	std::map<std::string, std::string>::const_iterator it = m_name2value.find(name);
	if(it != m_name2value.end())
	{
		return it->second;
	}
	return "";
}

inline RssChannel::iterator RssChannel::begin()
{
	return m_items.begin();
}

inline RssChannel::const_iterator RssChannel::begin() const
{
	return m_items.begin();
}

inline RssChannel::iterator RssChannel::end()
{
	return m_items.end();
}

inline RssChannel::const_iterator RssChannel::end() const
{
	return m_items.end();
}

inline void RssChannel::addItem(const RssItem &item)
{
	m_items.push_back(item);
}

inline size_t RssChannel::itemCount() const
{
	return m_items.size();
}

int RssChannel::getTTL() const
{
	return 0;
}

time_t RssChannel::getPubDate() const
{
	return 0;
}
